import request from '@/utils/request'

export function getDepartmentTree(params) {
  return request({
    url: 'api/sys/department/getTree',
    method: 'get',
    params
  })
}

export function getDepartments(params) {
  return request({
    url: 'api/sys/department/page',
    method: 'get',
    params
  })
}

export function findAll(ids) {
  const data = ids instanceof Array ? ids : Array.of(ids)
  return request({
    url: 'api/sys/department/findAll',
    method: 'post',
    data
  })
}

export function add(data) {
  return request({
    url: 'api/sys/department/insert',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/sys/department/delete',
    method: 'post',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/sys/department/update',
    method: 'post',
    data
  })
}

export default {add, edit, del, getDepartmentTree, findAll, getDepartments}
